package xyz.xuminghai.javafx_learn.stage;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.stage.Stage;

import java.util.Objects;

/**
 * 2023/1/9 9:58 星期一<br/>
 *
 * @author xuMingHai
 */
public class StageApplication extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Stage Application");
        Scene scene = new Scene(new Group(), 800, 600);
        // 设置F11全屏
        scene.getAccelerators().put(new KeyCodeCombination(KeyCode.F11), () -> primaryStage.setFullScreen(true));
        primaryStage.setScene(scene);
        // 图标
        primaryStage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream("ico.jpg"))));
        // 属性监听
        primaryStage.widthProperty().addListener((observable, oldValue, newValue) -> System.out.println("width = " + newValue));
        primaryStage.heightProperty().addListener((observable, oldValue, newValue) -> System.out.println("height = " + newValue));
        primaryStage.xProperty().addListener((observable, oldValue, newValue) -> System.out.println("x = " + newValue));
        primaryStage.yProperty().addListener((observable, oldValue, newValue) -> System.out.println("y = " + newValue));
        primaryStage.show();
    }
}
